package com.reremouse.rerebbs.web.mb.mag;

import com.reremouse.rerebbs.dao.IBbsUserDAO;
import com.reremouse.rerebbs.model.BbsUser;
import com.reremouse.util.SpringHelper;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ManagedBean
@ViewScoped
public class ListClientUser
        implements Serializable {
    List<BbsUser> casusList = new ArrayList();
    IBbsUserDAO cud = (IBbsUserDAO) SpringHelper.getSpringBean("BbsUserDAO");

    public List<BbsUser> getCasusList() {
        return this.casusList;
    }

    public void setCasusList(List<BbsUser> casusList) {
        this.casusList = casusList;
    }

    private void synchronizeDB() {
        this.casusList = this.cud.findAllBbsUser();
    }

    @PostConstruct
    public void init() {
        this.casusList = this.cud.findAllBbsUser();
    }

    public void deleteUser(long id) {
        this.cud.deleteBbsUser(id);
        synchronizeDB();
    }

    public void activateUser(long id) {
        BbsUser cu = this.cud.findBbsUser(id);
        if (!cu.getActivated().booleanValue()) {
            this.cud.activateUser(id);
        }
        synchronizeDB();
    }

    public void someAbleUser(long id) {
        BbsUser cu = this.cud.findBbsUser(id);
        if (cu.getEnabled().booleanValue()) {
            this.cud.disableUser(id);
        } else {
            this.cud.enableUser(id);
        }
        synchronizeDB();
    }

    public void someDelUser(long id) {
        BbsUser cu = this.cud.findBbsUser(id);
        if (!cu.isMarkDel()) {
            this.cud.enMarkDel(id);
        } else {
            this.cud.deMarkDel(id);
        }
        synchronizeDB();
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.rerebbs.web.mb.mag.ListClientUser

 * JD-Core Version:    0.7.0.1

 */